package com.web.dao;

import com.github.pagehelper.Page;
import com.web.controller.web.WebWithdrawController;
import com.web.entity.CompanyReport;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

/**
 * @author FDjavaone
 */
public interface CompanyReportMapper {
    @Delete({
        "delete from t_company_report",
        " where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into t_company_report (`add`, reduce,",
        " market_fund, company_fund, ",
        " profit_bal, core_bal, ",
        " un_withdraw, poundage, ",
        " withdraw_poundage, company_profit, ",
        " consume_bal, total, ",
        " reserve1, reserve2, ",
        "create_time, modify_time)",
        " values (#{add,jdbcType=VARCHAR}, #{reduce,jdbcType=VARCHAR}, ",
        " #{marketFund,jdbcType=VARCHAR}, #{companyFund,jdbcType=VARCHAR}, ",
        " #{profitBal,jdbcType=VARCHAR}, #{coreBal,jdbcType=VARCHAR}, ",
        " #{unWithdraw,jdbcType=VARCHAR}, #{poundage,jdbcType=VARCHAR}, ",
        " #{withdrawPoundage,jdbcType=VARCHAR}, #{companyProfit,jdbcType=VARCHAR}, ",
        " #{consumeBal,jdbcType=VARCHAR}, #{total,jdbcType=VARCHAR}, ",
        " #{reserve1,jdbcType=VARCHAR}, #{reserve2,jdbcType=VARCHAR}, ",
        " #{createTime,jdbcType=TIMESTAMP}, #{modifyTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(CompanyReport record);

    @InsertProvider(type=CompanyReportSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(CompanyReport record);

    @Select({
        "select",
        " id, add, reduce, market_fund, company_fund, profit_bal, core_bal, un_withdraw, ",
        " poundage, withdraw_poundage, company_profit, consume_bal, total, reserve1, reserve2, ",
        " create_time, modify_time",
        " from t_company_report",
        " where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="add", property="add", jdbcType=JdbcType.VARCHAR),
        @Result(column="reduce", property="reduce", jdbcType=JdbcType.VARCHAR),
        @Result(column="market_fund", property="marketFund", jdbcType=JdbcType.VARCHAR),
        @Result(column="company_fund", property="companyFund", jdbcType=JdbcType.VARCHAR),
        @Result(column="profit_bal", property="profitBal", jdbcType=JdbcType.VARCHAR),
        @Result(column="core_bal", property="coreBal", jdbcType=JdbcType.VARCHAR),
        @Result(column="un_withdraw", property="unWithdraw", jdbcType=JdbcType.VARCHAR),
        @Result(column="poundage", property="poundage", jdbcType=JdbcType.VARCHAR),
        @Result(column="withdraw_poundage", property="withdrawPoundage", jdbcType=JdbcType.VARCHAR),
        @Result(column="company_profit", property="companyProfit", jdbcType=JdbcType.VARCHAR),
        @Result(column="consume_bal", property="consumeBal", jdbcType=JdbcType.VARCHAR),
        @Result(column="total", property="total", jdbcType=JdbcType.VARCHAR),
        @Result(column="reserve1", property="reserve1", jdbcType=JdbcType.VARCHAR),
        @Result(column="reserve2", property="reserve2", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="modify_time", property="modifyTime", jdbcType=JdbcType.TIMESTAMP)
    })
    CompanyReport selectByPrimaryKey(Long id);

    @UpdateProvider(type=CompanyReportSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(CompanyReport record);

    @Update({
        "update t_company_report",
        " set add = #{add,jdbcType=VARCHAR},",
          " reduce = #{reduce,jdbcType=VARCHAR},",
          " market_fund = #{marketFund,jdbcType=VARCHAR},",
          " company_fund = #{companyFund,jdbcType=VARCHAR},",
          " profit_bal = #{profitBal,jdbcType=VARCHAR},",
          " core_bal = #{coreBal,jdbcType=VARCHAR},",
          " un_withdraw = #{unWithdraw,jdbcType=VARCHAR},",
          " poundage = #{poundage,jdbcType=VARCHAR},",
          " withdraw_poundage = #{withdrawPoundage,jdbcType=VARCHAR},",
          " company_profit = #{companyProfit,jdbcType=VARCHAR},",
          " consume_bal = #{consumeBal,jdbcType=VARCHAR},",
          " total = #{total,jdbcType=VARCHAR},",
          " reserve1 = #{reserve1,jdbcType=VARCHAR},",
          " reserve2 = #{reserve2,jdbcType=VARCHAR},",
          " create_time = #{createTime,jdbcType=TIMESTAMP},",
          " modify_time = #{modifyTime,jdbcType=TIMESTAMP}",
        " where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(CompanyReport record);

    @SelectProvider(type = CompanyReportSqlProvider.class, method = "selectByPage")
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
            @Result(column="add", property="add", jdbcType=JdbcType.VARCHAR),
            @Result(column="reduce", property="reduce", jdbcType=JdbcType.VARCHAR),
            @Result(column="market_fund", property="marketFund", jdbcType=JdbcType.VARCHAR),
            @Result(column="company_fund", property="companyFund", jdbcType=JdbcType.VARCHAR),
            @Result(column="profit_bal", property="profitBal", jdbcType=JdbcType.VARCHAR),
            @Result(column="core_bal", property="coreBal", jdbcType=JdbcType.VARCHAR),
            @Result(column="un_withdraw", property="unWithdraw", jdbcType=JdbcType.VARCHAR),
            @Result(column="poundage", property="poundage", jdbcType=JdbcType.VARCHAR),
            @Result(column="withdraw_poundage", property="withdrawPoundage", jdbcType=JdbcType.VARCHAR),
            @Result(column="company_profit", property="companyProfit", jdbcType=JdbcType.VARCHAR),
            @Result(column="consume_bal", property="consumeBal", jdbcType=JdbcType.VARCHAR),
            @Result(column="total", property="total", jdbcType=JdbcType.VARCHAR),
            @Result(column="reserve1", property="reserve1", jdbcType=JdbcType.VARCHAR),
            @Result(column="reserve2", property="reserve2", jdbcType=JdbcType.VARCHAR),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="modify_time", property="modifyTime", jdbcType=JdbcType.TIMESTAMP)
    })
    Page<CompanyReport> selectByPage(WebWithdrawController.WithdrawColumns withdrawColumns);
}